using System;
using ProjectBase.Utils;
using Iesi.Collections.Generic;

namespace Clanta.Core.Domain
{
    public class Presentation : VersionDomainObject<long, long>
    {
        #region Constructors

        protected Presentation()
        {
        }

        public Presentation(string name, Conference conference)
        {
            Name = name;
            Conference = conference;
        }

        #endregion

        #region Properties

        public virtual string Name
        {
            get { return name; }
            set
            {
                Check.Require(!string.IsNullOrEmpty(value), "The name must be provided");
                name = value;
            }
        }

        public virtual int? Green
        {
            get { return green; }
            set { green = value; }
        }

        public virtual int? Yellow
        {
            get { return yellow; }
            set { yellow = value; }
        }

        public virtual int? Red
        {
            get { return red; }
            set { red = value; }
        }

        /// <summary>
        /// The number of participants that actually attended the presentation.
        /// This may be an estimate.
        /// </summary>
        public virtual int? NoOfParticipants
        {
            get { return noOfParticipants; }
            set { noOfParticipants = value; }
        }

        /// <summary>
        /// The conference associated with the track. Always non-null.
        /// </summary>
        public virtual Conference Conference
        {
            get { return conference; }
            protected set
            {
                Check.Require(value != null, "The conference that this presentation belongs to must be provided");
                conference = value;
            }
        }

        /// <summary>
        /// Optional track. May be null. If defined, it must belong to the same
        /// conference as this presentation.
        /// </summary>
        public virtual Track Track
        {
            get { return track; }
            set { track = value; }
        }

        /// <summary>
        /// The speakers associated with this presentation. These must belong
        /// to the same conference as this presentation.
        /// </summary>
        public virtual ISet<Speaker> Speakers
        {
            get { return speakers; }
            protected set
            {
                Check.Require(value != null, "The speakers associated with this presentation must not be null");
                speakers = value;
            }
        }

        /// <summary>
        /// Indicates the date and time when the presentation started
        /// </summary>
        public virtual DateTime? PresentationStart
        {
            get { return presentationStart; }
            set { presentationStart = value; }
        }

        #endregion

        #region Fields

        private string name;

        private int? green;

        private int? yellow;

        private int? red;

        private int? noOfParticipants;

        private Conference conference;

        private Track track;

        private ISet<Speaker> speakers = new HashedSet<Speaker>();

        private DateTime? presentationStart;

        #endregion
    }
}
